using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;

namespace Impact.Infrastructure.Configuration
{
    /// <summary>
    /// container for all settings pertaining to the impact application
    /// </summary>
    public class ImpactSettings : ConfigurationSection, ICloneable
    {
        /// <summary>
        /// default constructor
        /// </summary>
        public ImpactSettings()
        {
        }

        /// <summary>
        /// the default page that will be loaded when a user does not request a specific page
        /// </summary>
        [ConfigurationProperty("defaultPage")]
        public string DefaultPage
        {
            get { return (string)base["defaultPage"]; }
            set { base["defaultPage"] = value; }
        }

        /// <summary>
        /// configuration property for the 'footerText' field
        /// </summary>
        [ConfigurationProperty("footerText")]
        public string FooterText
        {
            get { return (string)base["footerText"]; }
            set { base["footerText"] = value; }
        }

        /// <summary>
        /// configuration property for the 'pageTitlePrefix' field
        /// </summary>
        [ConfigurationProperty("pageTitlePrefix")]
        public string PageTitlePrefix
        {
            get { return (string)base["pageTitlePrefix"]; }
            set { base["pageTitlePrefix"] = value; }
        }

        /// <summary>
        /// configuration property for the 'webmasterEmail' field
        /// </summary>
        [ConfigurationProperty("webmasterEmail")]
        public string WebmasterEmail
        {
            get { return (string)base["webmasterEmail"]; }
            set { base["webmasterEmail"] = value; }
        }

        /// <summary>
        /// configuration property for the 'menuStyle' field
        /// </summary>
        [ConfigurationProperty("menuStyle")]
        public string MenuStyle
        {
            get { return (string)base["menuStyle"]; }
            set { base["menuStyle"] = value; }
        }

        /// <summary>
        /// configuration property for the 'articleFolder' field
        /// </summary>
        [ConfigurationProperty("articleFolder")]
        public string ArticleFolder
        {
            get { return (string)base["articleFolder"]; }
            set { base["articleFolder"] = value; }
        }

        /// <summary>
        /// configuration property for the 'categoryTemplate' field
        /// </summary>
        [ConfigurationProperty("categoryTemplate")]
        public string CategoryTemplate
        {
            get { return (string)base["categoryTemplate"]; }
            set { base["categoryTemplate"] = value; }
        }

        /// <summary>
        /// configuration property for the 'articleTemplate' field
        /// </summary>
        [ConfigurationProperty("articleTemplate")]
        public string ArticleTemplate
        {
            get { return (string)base["articleTemplate"]; }
            set { base["articleTemplate"] = value; }
        }

        /// <summary>
        /// configuration property for the 'tagTemplate' field
        /// </summary>
        [ConfigurationProperty("tagTemplate")]
        public string TagTemplate
        {
            get { return (string)base["tagTemplate"]; }
            set { base["tagTemplate"] = value; }
        }

        /// <summary>
        /// configuration property for the 'searchTemplate' field
        /// </summary>
        [ConfigurationProperty("searchTemplate")]
        public string SearchTemplate
        {
            get { return (string)base["searchTemplate"]; }
            set { base["searchTemplate"] = value; }
        }

        /// <summary>
        /// configuration property for the 'rssTitle' field
        /// </summary>
        [ConfigurationProperty("rssTitle")]
        public string RssTitle
        {
            get { return (string)base["rssTitle"]; }
            set { base["rssTitle"] = value; }
        }

        /// <summary>
        /// configuration property for the 'rssDescription' field
        /// </summary>
        [ConfigurationProperty("rssDescription")]
        public string RssDescription
        {
            get { return (string)base["rssDescription"]; }
            set { base["rssDescription"] = value; }
        }


        /// <summary>
        /// gets the collection of plugins configured for use in impact
        /// </summary>
        [ConfigurationProperty("plugins", IsRequired = false, IsDefaultCollection = true)]
        public PluginSettingsCollection Plugins
        {
            get { return (PluginSettingsCollection)base["plugins"]; }
            set { base["plugins"] = value; }
        }        


        #region ICloneable Members

        /// <summary>
        /// creates a new ImpactSettings object with the same values as this one
        /// </summary>
        /// <returns></returns>
        public object Clone()
        {
            ImpactSettings newSettings = new ImpactSettings();
            newSettings.ArticleFolder = this.ArticleFolder;
            newSettings.ArticleTemplate = this.ArticleTemplate;
            newSettings.CategoryTemplate = this.CategoryTemplate;
            newSettings.DefaultPage = this.DefaultPage;
            newSettings.FooterText = this.FooterText;
            newSettings.MenuStyle = this.MenuStyle;
            newSettings.PageTitlePrefix = this.PageTitlePrefix;
            newSettings.TagTemplate = this.TagTemplate;
            newSettings.WebmasterEmail = this.WebmasterEmail;

            return newSettings;
        }

        #endregion
    }

    /// <summary>
    /// describes the various styles of menus available
    /// </summary>
    public struct MenuStyle
    {
        /// <summary>
        /// popup menu
        /// </summary>
        public const string Popup = "popup";
        /// <summary>
        /// flat static menu
        /// </summary>
        public const string Flat = "flat";
    }

}
